<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php
    require_once("class.connectSQL.inc");
    
    //instancia da classe
    $banco = new connectSQL();
	$banco1 = new connectSQL();
	$banco2 = new connectSQL();
	$banco3 = new connectSQL();
	$banco4 = new connectSQL();
	if(isset($_GET["excluir"])){
		
		 $resultado1 = $banco2->Query("SELECT * FROM fotogaleria where idfoto = ".$_GET["cod"]);
                 
                 foreach ($resultado1 as $resut1){
                     $caminho = $resut1["caminho"];
                     
                    }
                    chmod($caminho,0777);
                    unlink($caminho);
                    $sql = "Delete from fotogaleria where idfoto = ".$_GET["cod"];
				//die($sql);
				
                    $banco3->Generico($sql);
				//die($_POST["acao"]);
				$msg = "Excluido com sucesso";
                    //die($caminho);
        }
		
?>

	<head>
	<?php include "head.php"; ?>
 <script>   
    function validar(form){
    if(form.marca.value == ''){
        alert("O campo Marca é obrigatório.");
        return false;
    }
   
    return true;
	}
  </script>
	</head>
	<body>
    	<!-- Header -->
        <div id="header">
            <?php include "sair.php"; ?>
            
            <!-- Header. Main part -->
            <div id="header-main">
                <div class="container_12">
                    <div class="grid_12">
                        <div id="logo">
                            <ul id="nav">
                                <li id="current"><a href="">Fotos</a></li>
                                
                            </ul>
                        </div><!-- End. #Logo -->
                    </div><!-- End. .grid_12-->
                    <div style="clear: both;"></div>
                </div><!-- End. .container_12 -->
            </div> <!-- End #header-main -->
            <div style="clear: both;"></div>
            <!-- Sub navigation -->
          
        </div> <!-- End #header -->
        
		<div class="container_12" align="center" >
        

            <div class="module">
                     <h2><span>Cadastro de Fotos</span></h2>
                        
                     <div class="module-body">
                         <form method="post" enctype="multipart/form-data" action="recebeUpload_galeria.php?cod=<?php echo $_GET["cod"]; ?>">
                        Nome:     <input type="text" class="input-medium" id="nome" name="nome"   /> <br>
                        Selecione uma imagem: <input name="arquivo" type="file" />
                            <br />
                        <input type="submit" value="Salvar" />
                         
                         
<!--                         <form action="cadsobre.php"  onsubmit="return validar(this);" id="form" method="post">
                        
                            <p align="left">
                            
                            
                                
                                <input type="hidden" name="idpgsobre" id="idpgsobre" value="1" />
                                
                            </p>
                            
                            <?php
					 
//					 	 	 $resultado = $banco2->Query("SELECT * FROM pgsobre where idpgsobre = 1");
//							 foreach ($resultado as $resut){
//								$titulo =  $resut['titulo'];
//                                                                $texto =  $resut['texto'];
//                                                                
//                                                               
//							 }
						 
				?>
                            
                            <p align="left">
                                <label>Título</label>
                                <input type="text" class="input-medium" id="titulo" name="titulo" value="<?php echo $titulo; ?>" />
                                
                            </p>
                            <p align="left">
                                <label>Descriçao</label>
                                <textarea cols="50" rows="40" name="texto"><?php echo $texto; ?></textarea>
                            </p>
                            
                            
                           <input type="hidden" name="acao" value="A" />
                            <fieldset>
                                <input class="submit-green" type="submit" value="Salvar" /> 
                                <input class="submit-gray"  type="reset" value="Cancelar" />
                            </fieldset>
                        </form>-->
                     </div> 
                      <!-- End .module-body -->
					 
                </div>  <!-- End .module -->
				<?php 
				if(isset($msg)){
				echo "<span class='notification n-success'>".$msg."</span>";
				}
				?>
				
				<?php
					 $resultado = $banco->Query("SELECT * FROM fotogaleria where id_galeria = ".$_GET["cod"]);
				?>
                     
        
                <!-- Example table -->
                <div class="module">
                	<h2>Serviços</h2>
                    
                    <div class="module-table-body">
                    	<form action="">
                        <table id="myTable" class="tablesorter">
                        	
                                <tr>
                                    <th style="width:5%">#</th>
                                    <th style="width:20%">Nome</th>
                                    <th style="width:20%">Imagem</th>
                                    <th style="width:15%"></th>
                                </tr>
                            
                            <tbody>
                            <?php
                            
    
        foreach ($resultado as $resut){
        echo "<tr>";
		echo "<td>". $resut['idfoto']."</td>";
                echo "<td>". $resut['nome']."</td>";
		echo  "<td><img src='". $resut['caminho']."'  width='40' height='40' alt='edit' /></td>";
                
		?>
        <?php ?>
        <td>
        <a href="cadfoto_galeria.php?excluir=1&cod=<?php echo $resut['idfoto']; ?>"><img src="bin.gif" tppabs="http://www.xooom.pl/work/magicadmin/images/bin.gif" width="30" height="30" alt="delete" /></a>
        </td>
            <?php  
		
			
  		echo "</tr>";
		}
   		                  ?>  
                                
                                             
                     
                     
                      </tbody>
                        </table>
                        </form>
                     
                     
                 </div>  
        
                <!-- Example table -->
                <!-- End .container_12 -->
		
         
        <?php include "footer.php"; ?>
        
	</body>
</html>